package web.kx;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Properties;
import java.util.Map.Entry;

public class Dish {
	public int id = 0;
	public int time = 0;
	static Hashtable<String,Dish> ht = new Hashtable<String,Dish> ();
	public Dish(int id , int time){
		this.id=id;this.time=time;
	}
	private static void put(String name,int id,int time) {
		ht.put(name, new Dish(id,time));
	}
	public static Dish get(String s) {
		return ht.get(s);
	}
	private static Properties properties;

	static {
		properties = new Properties();
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("./GlobalCfg/dishs.txt"), "gb2312"));
			properties.load(in);
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		} catch (FileNotFoundException e1) {
			e1.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		} 
		for (Iterator iterator = properties.entrySet().iterator(); iterator.hasNext();) {
			Entry type = (Entry) iterator.next();
			String value =(String) type.getValue();
			String[] split = value.split("[,\\*]");
			String key = (String) type.getKey();
			Main.logger.info( key+"="+value+"size="+split.length);
			if(split.length == 2 ) {
				put(key,Integer.parseInt(split[0]),Integer.parseInt(split[1]));
			}else if(split.length == 3 ) {
				put(key,Integer.parseInt(split[0]),Integer.parseInt(split[1])*Integer.parseInt(split[2]));
			}
		}
	}
	public static String getProperty(String s) {
		return (String) properties.get(s);
	}
	public static void main(String[] ss) {
		System.out.println("hello");
		System.out.println(ht);
	}
//	static {
//		put("宫保鸡丁",4,15);
//		put("黯然销魂饭",35,4*60);
//		put("冰糖木瓜雪蛤",63,4*60);
//		put("世界杯套餐",82,4*60);
//		put("冰糖燕窝",66,12*60);
//		put("糖醋小排",41,3*60);
//		put("长寿面",70,120);
//		put("三鲜鱼翅汤",38,48*60);
//		put("毛蟹年糕",36,120);
//		put("芝士蛋糕",50,2*60);
//		put("窝窝头", 46,18 * 60);
//		put("凉拌野菜",68,2 * 60);
//		put("菠萝",15,12 * 60);
//		put("枸杞",60,30);
//		put("红烧茄子",5,5);
//		put("冰糖肘子",37,8*60);
//		put("饺子",45,30);
//		put("毛血旺",31,30);
//		put("葱包桧",32,20);
//		put("陕西凉皮",10,10);
//		put("棒棒鸡",39,20);
//		put("灌汤包",33,10);
//		put("它似蜜",64,30);
//		put("红焖大虾",65,6*60);
//		put("水煮鱼",27,5*60);
//		put("文昌鸡",42,4*60);
//		put("东坡肉",16,720);
//	}
}